package com.xinli.xinlifm.view.activity.player;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.xinli.xinlifm.R;
import com.xinli.xinlifm.http.bean.player.RecommendBean;
import com.xinli.xinlifm.mvp.model.SuperModel;
import com.xinli.xinlifm.view.adapter.find.RecommendAdapter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;

import in.srain.cube.views.ptr.PtrClassicFrameLayout;

public class RecommendActivity extends AppCompatActivity implements View.OnClickListener {

    private RecyclerView recyclerView;
    private PtrClassicFrameLayout ptrFrameLayout;
    private RecommendAdapter adapter;
    private ImageView back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recommend);
        back = (ImageView) findViewById(R.id.reco_back);
        back.setOnClickListener(this);
        recyclerView = (RecyclerView) findViewById(R.id.recommend_recycler);
        adapter = new RecommendAdapter(this,new ArrayList<RecommendBean.DataBean>());
        recyclerView.setAdapter(adapter);
        ptrFrameLayout = (PtrClassicFrameLayout) findViewById(R.id.ptr_frame_layout);
        Intent intent = getIntent();
        String id = intent.getStringExtra("ids");
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        Log.e("自定义标签", "类名==RecommendActivity" + "方法名==onCreate=====:" + id);
        int i = Integer.parseInt(id);
        Log.e("自定义标签", "类名==RecommendActivity" + "方法名==onCreate=====:" + i);
        new SuperModel().getRecommendData(0,i,10);
    }
    @Subscribe
    public void showRecommend(RecommendBean recommendBean){
        adapter.addAll(recommendBean.getData());
    }

    @Override
    public void onClick(View v) {
        finish();
    }
}
